﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="copyright" content=""/>
    <title>微博后台</title>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/wu.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/icon.css"/>
    <script type="text/javascript" src="__PUBLIC__/js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/jquery.form.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/jquery.json.js"></script>
</head>
<body class="easyui-layout">
<!-- begin of header -->
<div class="wu-header" data-options="region:'north',border:false,split:true">
    <div class="wu-header-left">
        <h1>后盾微博后台</h1>
    </div>
    <div class="wu-header-right">
        <p>当前用户：<strong class="easyui-tooltip" title="欢迎您！">{$Think.session.loginuser}</strong></p>
        <p><a href="{:U('Home/Index/index','','')}">网站首页</a>|<a href="#" onclick="closeAll()">清除缓存</a>|<a href="{:U('Index/logOut','','')}">注销</a></p>
    </div>
</div>
<!-- end of header -->
<!-- begin of sidebar -->
<div class="wu-sidebar" data-options="region:'west',split:true,border:true,title:'导航菜单'">
    <div class="easyui-accordion" data-options="border:false,fit:true">
        <div title="用户管理" data-options="iconCls:'icon-application-cascade'" style="padding:5px;">
            <ul class="easyui-tree wu-side-tree">
                <li iconCls="icon-users"><a href="javascript:void(0)" data-icon="icon-users"
                                            data-link="{:U('User/index','','')}" iframe="0">微博用户</a></li>
                <li iconCls="icon-user-group"><a href="javascript:void(0)" data-icon="icon-user-group"
                                                 data-link="{:U('User/adminUser','','')}" iframe="0">系统用户</a></li>
            </ul>
        </div>
        <div title="微博管理" data-options="iconCls:'icon-application-form-edit'" style="padding:5px;">
            <ul class="easyui-tree wu-side-tree">
                <li iconCls="icon-book"><a href="javascript:void(0)" data-icon="icon-book"
                                           data-link="{:U('Weibo/index','','')}" iframe="0">微博列表</a></li>
                <li iconCls="icon-application-osx-error"><a href="javascript:void(0)"
                                                            data-icon="icon-application-osx-error"
                                                            data-link="{:U('Weibo/comment','','')}" iframe="0">评论列表</a></li>
            </ul>
        </div>
        <div title="系统设置" data-options="iconCls:'icon-wrench'" style="padding:5px;">
            <ul class="easyui-tree wu-side-tree">
                <li iconCls="icon-chart-organisation"><a href="javascript:void(0)" data-icon="icon-chart-organisation"
                                                         data-link="{:U('System/index','','')}" iframe="0">网站设置</a></li>
                <li iconCls="icon-cog"><a href="javascript:void(0)" data-icon="icon-cog" data-link="{:U('User/editPwd','','')}"
                                          iframe="0">修改密码</a></li>
            </ul>
        </div>
    </div>
</div>
<!-- end of sidebar -->
<!-- begin of main -->
<div class="wu-main" data-options="region:'center'">
    <div id="wu-tabs" class="easyui-tabs" data-options="border:false,fit:true">
        <div title="首页"
             data-options="href:'{:U('Admin/Index/info','','')}',closable:false,iconCls:'icon-tip',cls:'pd3'"></div>
    </div>
</div>
<!-- end of main -->
<!-- begin of footer -->
<div class="wu-footer" data-options="region:'south',border:true,split:true">
    &copy; 2018 Copy Rights Reserved
</div>
<!-- end of footer -->
<script type="text/javascript">
    $(function () {
        $('.wu-side-tree a').bind("click", function () {
            var title = $(this).text();
            var url = $(this).attr('data-link');
            var iconCls = $(this).attr('data-icon');
            var iframe = $(this).attr('iframe') == 1 ? true : false;
            addTab(title, url, iconCls, iframe);
        });
    })

    /**
     * Name 载入树形菜单
     */
    $('#wu-side-tree').tree({
        url: 'temp/menu.php',
        cache: false,
        onClick: function (node) {
            var url = node.attributes['url'];
            if (url == null || url == "") {
                return false;
            }
            else {
                addTab(node.text, url, '', node.attributes['iframe']);
            }
        }
    });


    /**
     * Name 添加菜单选项
     * Param title 名称
     * Param href 链接
     * Param iconCls 图标样式
     * Param iframe 链接跳转方式（true为iframe，false为href）
     */
    function addTab(title, href, iconCls, iframe) {
        var tabPanel = $('#wu-tabs');
        if (!tabPanel.tabs('exists', title)) {
            var content = '<iframe scrolling="auto" frameborder="0"  src="' + href + '" style="width:100%;height:100%;"></iframe>';
            if (iframe) {
                tabPanel.tabs('add', {
                    title: title,
                    content: content,
                    iconCls: iconCls,
                    fit: true,
                    cls: 'pd3',
                    closable: true
                });
            }
            else {
                tabPanel.tabs('add', {
                    title: title,
                    href: href,
                    iconCls: iconCls,
                    fit: true,
                    cls: 'pd3',
                    closable: true
                });
            }
        }
        else {
            tabPanel.tabs('select', title);
        }
    }

    /**
     * Name 移除菜单选项
     */
    function removeTab() {
        var tabPanel = $('#wu-tabs');
        var tab = tabPanel.tabs('getSelected');
        if (tab) {
            var index = tabPanel.tabs('getTabIndex', tab);
            tabPanel.tabs('close', index);
        }
    }

    /**
     *移除所有菜单项
     */
    function closeAll() {
        $.messager.confirm('清除缓存', '确认是否关闭所有选项卡清除缓存?', function(r){
            if (r){
                $("#wu-tabs li").each(function(index, obj) {
                    //获取所有可关闭的选项卡
                    var tab = $(".tabs-closable", this).text();
                    $(".easyui-tabs").tabs('close', tab);
                });
                $("#close").remove();//同时把此按钮关闭
            }
        });
    }


    //将时间戳转换成日期
    function toDateString(d, format) {
        var date = new Date(d || new Date())
            , ymd = [
            this.digit(date.getFullYear(), 4)
            , this.digit(date.getMonth() + 1)
            , this.digit(date.getDate())
        ]
            , hms = [
            this.digit(date.getHours())
            , this.digit(date.getMinutes())
            , this.digit(date.getSeconds())
        ];
        format = format || 'yyyy年MM月dd日 HH点mm分ss秒';
        return format.replace(/yyyy/g, ymd[0])
            .replace(/MM/g, ymd[1])
            .replace(/dd/g, ymd[2])
            .replace(/HH/g, hms[0])
            .replace(/mm/g, hms[1])
            .replace(/ss/g, hms[2]);
    };

    //数字前置加零
    function digit(num, length, end) {
        var str = '';
        num = String(num);
        length = length || 2;
        for (var i = num.length; i < length; i++) {
            str += '0';
        }
        return num < Math.pow(10, length) ? str + (num | 0) : num;
    }
</script>
</body>
</html>
